package com.example.cloudmusic

import android.util.Log
import com.bumptech.glide.Glide
import com.example.cloudmusic.databinding.ActivityMainBinding
import com.example.lib_common_ui.base.BaseActivity
import com.example.lib_leancloud.LeanCloudManager
import com.example.lib_leancloud.model.Chart

class MainActivity : BaseActivity<ActivityMainBinding>(){
    override fun initUI() {

        LeanCloudManager.instance.loadAdv { manager, advs ->
            val url = manager.getRandomAdv()
            Log.v( "pxd","adv = ${url.image}")
            Glide.with(this).load(url.image).into(binding.imageView)
        }

        LeanCloudManager.instance.loadCharts{manager,result->
            result.forEach{chart: Chart ->
                manager.loadMusics(chart.id){musicList ->
                    Log.v("pxd",chart.name)
                    musicList.forEach { music ->
                        Log.v("pxd",music.title)
                    }
                }

            }

        }
    }
}